package com.third.customer.site.controller.resp;

import com.third.customer.model.tables.Area;
import com.third.customer.service.utils.TimeUtils;
import lombok.Data;

/**
 * Created by hehuaichun on 2020/6/27.
 */
@Data
public class AreaResp {

    private String id;

    private String companyId;

    private String county;

    private String community;

    private String updatedAt;

    private String createdAt;

    public static AreaResp convert(Area area){
        AreaResp resp = new AreaResp();
        resp.setId(String.valueOf(area.getId()));
        resp.setCompanyId(String.valueOf(area.getCompanyId()));
        resp.setCounty(area.getCounty());
        resp.setCommunity(area.getCommunity());
        if(area.getUpdatedAt()!= null){
            resp.setUpdatedAt(TimeUtils.dateToString(area.getUpdatedAt()));
        }
        if(area.getCreatedAt() != null){
            resp.setCreatedAt(TimeUtils.dateToString(area.getCreatedAt()));
        }
        return resp;
    }
}
